package com.apply.config;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.concurrent.ExecutorService;

/**
 * @author tianp
 */
@Component
@Scope("singleton")
public class EmailManager {
    private ExecutorService executorService;

    @PostConstruct
    public void init() {
        executorService = EmailThreadFactory.getEmailThreadPool("send-eamil", 10);
    }

    public void sendEmail(List<String> toAddresses, String subject, String content, String directory, String fileName) {
        executorService.execute(() -> {
                    EmailUtils.send(toAddresses, subject, content, directory, fileName);
                }
        );
    }
}
